<?php
class lib_company_diaocha_log extends lib_base{
	public $table_name = "qc_company_diaocha_log";
    public $pk = "id";

	public function getList($cond,$h5=0){

        if($h5==1){
            $result = $this->get_loaddata($cond,'id desc','*',10);
        }else{
            $result = $this->get_pagelist($cond,'id desc','*',20);
        }
        if($result){
            $lists = $result['list'];

            foreach ($lists as $val) {

                if($val['admin_ids']){
                    $val['admin_ids'] = explode(',',$val['admin_ids']);
                }
                $list[] = $val;
            }


            $data['list'] = $list;
            $data['showPage'] = $result['showPage'];
            $data['total'] = $result['total'];

            return $data;
        }else{
            return false;
        }

    }

    public function add_log($order_id,$data){
		$order = D('company_order')->get_info($order_id);

		$msg = array(
    		'1'=>'发布了订单',
    		'2'=>'派送了订单',
    		'3'=>'接受了订单',
    		'4'=>'订单已完成',
    		'5'=>'订单已确认',
    		'6'=>'评价了订单',
    		'7'=>'结算了订单',
    		'99'=>'取消了订单',
    	);

    	$intro['msg'] = $msg[$order['order_status']];
        if($order['order_status'] > 1){
            // if($data['photo']) $intro['photo'] = joinStr($data['photo']);
			if($data['photo']){
				$intro['photo'] = json_decode($data['photo'],true);
			}
            if($data['intro']) $intro['intro'] = $data['intro'];
		}

    	if($order){
	        $arrBase = array(
				'company_id' =>$order['company_id'],
	        	'order_id' =>$order_id,
                'device_id' =>$order['device_id'],
				'intro' =>serialize($intro),
				'order_status' =>$order['order_status'],
				'status' =>1,
				'add_time'=>date('Y-m-d H:i:s'),
			);
			return $this->add($arrBase);
		}

    }
}